home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / colordh.exe / COLOR_AP.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-15  |  21KB  |  599 lines

  1. {*--------------------------------------------------------------------------*}
  2. {*  Color_App  1.3  -- add colors to your Application dialogs.              *}
  3. {*        by Doug Hood.  CIS 70324,3336                                     *}
  4. {*           Released to the PUBLIC DOMAIN.                                 *}
  5. {*            (in a small effort to repay my debt to the PUBLIC Domain)     *}
  6. {*--------------------------------------------------------------------------*}
  7. {*    Version 1.3 adds support for BP 7.0 /TVision 2.0                      *}
  8. {*      using conditional compilation for BOTH BP6.0 and BP7.0 support      *}
  9. {*--------------------------------------------------------------------------*}
  10. {*    Version 1.2 adds Color_InputLine Beeping when FULL.                   *}
  11. {*--------------------------------------------------------------------------*}
  12. {*    Version 1.1 adds Color_StaticText2 (only the chars are colored)       *}
  13. {*--------------------------------------------------------------------------*}
  14. {*   To Use the COLOR features (Buttons, etc) you must:                     *}
  15. {*     0: Have your application be a PCOLOR_APP from this unit!!!!          *}
  16. {*     1: Have your DIALOG be a PCOLOR_DIALOG from this unit!               *}
  17. {*     2: Pascal-Code the PCOLOR_BUTTONS/PCOLOR_STATICTEXT exactly          *}
  18. {*        the same as if they were 'normal' TButton/TStaticText.            *}
  19. {*     3: My 'FIELDS_C' also unit knows about these COLOR objects.          *}
  20. {*--------------------------------------------------------------------------*}
  21. {*--------------------------------------------------------------------------*}
  22. {*  NOTE: i am taking advantage of the upper 8 colors by disabling the      *}
  23. {*        ability to 'flash'                                                *}
  24. {*--------------------------------------------------------------------------*}
  25. UNIT Color_App;    {Colored Application Buttons/TEXT!!}
  26.  
  27.  
  28. INTERFACE
  29. USES App,       {TVISION, modified version to handle COLOR buttons!}
  30.      Dialogs,   {TVISION, button}
  31.      Views,     {TVision, titlestr}
  32.      Drivers,   {TEvent}
  33.      Objects;   {TVision, misc}
  34.  
  35. CONST
  36.   Button_Color_Default :byte = 0;     {green}
  37.   Button_Black         :byte = 1;
  38.   Button_Dk_Blue       :byte = 2;
  39.   Button_Green         :byte = 3;
  40.   Button_Cyan          :byte = 4;
  41.   Button_Red           :byte = 5;
  42.   Button_Purple        :byte = 6;
  43.   Button_Brown         :byte = 7;
  44.   Button_Grey          :byte = 8;
  45.  
  46.   Button_Dk_Grey       :byte = 9;
  47.   Button_Lt_Blue       :byte = 10;
  48.   Button_Lt_Green      :byte = 11;
  49.   Button_Lt_Cyan       :byte = 12;
  50.   Button_Lt_Red        :byte = 13;
  51.   Button_Lt_Purple     :byte = 14;
  52.   Button_Yellow        :byte = 15;
  53.   Button_White         :byte = 16;
  54.  
  55. {*************************************************************************}
  56. {*  TAPPLICATION (TVision)                                               *}
  57. {*    Method:GetPalette                                                  *}
  58. {*        |                                                              *}
  59. {*        +Color_App                                                     *}
  60. {*           Method:GetPalette                                           *}
  61. {*           Method:HandleEvent (beep when full)                         *}
  62. {*                                                                       *}
  63. {*                                                                       *}
  64. {*  TDIALOG (Tvision)                                                    *}
  65. {*    Method:Init         (turn off blink ability to get 8 more colors)  *}
  66. {*    Method:GetPalette                                                  *}
  67. {*        |                                                              *}
  68. {*        + Color_Dialog (in unit Color_App)                             *}
  69. {*           Method:GetPalette                                           *}
  70. {*                                                                       *}
  71. {*                                                                       *}
  72. {*  TBUTTON (TVision)                                                    *}
  73. {*    Constructor:Init                                                   *}
  74. {*    Method:GetPalette                                                  *}
  75. {*        |                                                              *}
  76. {*        + Color_Button (in unit Color_App)                             *}
  77. {*           Constructor:Init   (add color param)                        *}
  78. {*           Method:GetPalette                                           *}
  79. {*************************************************************************}
  80.  
  81.  
  82. TYPE
  83.   PColor_InputLine = ^Color_Inputline;
  84.   Color_InputLine = OBJECT(TInputLine)
  85.     constructor Init (var Bounds: OBJECTS.TRect; AMaxLen: Integer;
  86.                       Button_Color_ID : byte);   {new parameter!}
  87.     function GetPalette : PPalette; virtual;     {MUST Override!}
  88.     procedure HandleEvent (var Event : TEvent); virtual;
  89.                                                {beep when too long}
  90.   private
  91.     Color         : word;
  92.   end; {color_inputline}
  93.  
  94.  
  95.   PColor_Button = ^Color_Button;
  96.   Color_Button = object(DIALOGS.TButton)
  97.     constructor Init (var Bounds      : OBJECTS.TRect;
  98.                       ATitle          : VIEWS.TTitleStr;
  99.                       ACommand        : Word;
  100.                       AFlags          : Byte;
  101.                       Button_Color_ID : byte);   {new parameter!}
  102.     function GetPalette : PPalette; virtual;     {MUST Override!}
  103.     procedure New_Color (Button_Color_ID : Byte);
  104.     function Get_Color : integer;
  105.     procedure Hide_Shadow;
  106.   private
  107.     Color         : word;
  108.     Shadow_Hidden : boolean;
  109.   end; {Color_Button}
  110.  
  111.   {*-----------------------------------------------------------------*}
  112.   {* The background, not the chars is colored.                       *}
  113.   {*-----------------------------------------------------------------*}
  114.   PColor_StaticText = ^Color_StaticText;
  115.   Color_StaticText = object(DIALOGS.TStaticText)
  116.     constructor Init (var Bounds      : OBJECTS.TRect;
  117.                       AText           : string;
  118.                       Button_Color_ID : byte);   {new parameter!}
  119.     function GetPalette : PPalette; virtual;     {MUST Override!}
  120.   private
  121.     Color         : word;
  122.   end; {Color_StaticText}
  123.  
  124.   {*-----------------------------------------------------------------*}
  125.   {* Only the chars, not the background is colored                   *}
  126.   {*-----------------------------------------------------------------*}
  127.   PColor_StaticText2 = ^Color_StaticText2;
  128.   Color_StaticText2 = object(Color_StaticText)
  129.     function GetPalette : PPalette; virtual;     {MUST Override!}
  130.   end; {Color_StaticText2}
  131.  
  132.  
  133.   PColor_Dialog = ^Color_Dialog;
  134.   Color_Dialog = object(TDialog)
  135.     constructor init (var bounds: TRect; ATitle: TTitleStr);
  136.     function GetPalette : PPalette; virtual;     {MUST Override!}
  137.   end; {Color_Dialog}
  138.  
  139.  
  140.   PColor_Application = ^Color_Application;
  141.                  {this elimates need to tweak APP.pas}
  142.   Color_Application = object(TApplication)
  143.     function GetPalette : PPalette; virtual;     {MUST Override!}
  144.   end; {Color_Application}
  145.  
  146.   {*-----------------------------------------------------------*}
  147.   {* If you want blinking, you must call SetBlink(TRUE)        *}
  148.   {* after a color dialog                                      *}
  149.   {* NOTE: This should be called (FALSE) when returning        *}
  150.   {*       from a DOS_SHELL. (since another program may        *}
  151.   {*       haved changed the state behing my back)             *}
  152.   {*-----------------------------------------------------------*}
  153.   procedure SetBlink(State: Boolean);
  154.  
  155.  
  156.  
  157.  
  158. {*************************************************************************}
  159. {*************************************************************************}
  160. {*************************************************************************}
  161. IMPLEMENTATION
  162.  
  163.  
  164. {*************************************************************************}